import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:计算字符串的编辑距离
 * User: wangxin
 * Date: 2024-10-19
 * Time: 18:11
 */
public class test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        String s1 = in.nextLine();
        String s2 = in.nextLine();
        int[][] dp = new int[s1.length()+ 1][s2.length() + 1];
        for(int i = 1;i <= s1.length();i++){
            dp[i][0] = i;
        }
        for(int i = 1;i <= s2.length();i++){
            dp[0][i] = i;
        }
        for(int i = 1;i <= s1.length();i++){
            for(int j = 1;j <= s2.length();j++){
                if(s1.charAt(i - 1) == s2.charAt(j - 1)){
                    dp[i][j] = dp[i-1][j-1];
                }else{
                    dp[i][j] = Math.min(dp[i-1][j-1] + 1,Math.min(dp[i-1][j] + 1,dp[i][j-1] + 1));
                }
            }
        }
        System.out.println(dp[s1.length()][s2.length()]);

    }
}
